package com.itheima.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 定义Controller注解
 */
@RestController
public class HelloWorldController {
    //使用注解来获取配置文件里面的参数
    @Value("${person.name}")
    private String name;
    @Autowired
    private Environment enc;
    @Autowired
    private Person person;
    //创建一个方法,定义一个路劲
    //需要编写一个引导类,启动这个方法
    @RequestMapping("/hello")
    public String helloworld(){
        System.out.println(enc.getProperty("person.name"));
        System.out.println("-----------------------------");
        System.out.println(person);
        //获取数组
        String[] address = person.getAddress();
        //遍历数组获取数据
        for (String s : address) {
            System.out.println(s);
        }
        return "Hello SpringBoot!!!";
    }
}
